package com.tandashi.springbootstudy01.config;

import com.tandashi.springbootstudy01.security.shiro.StudyPrincipal;
import org.apache.shiro.subject.Subject;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class AppUserSwaggerFilter extends AppUserFilter{

    @Override
    protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
        //是否内网判断

        Subject subject = getSubject(request,response);
        if(!subject.isAuthenticated()){
            return false;
        }

        StudyPrincipal studyPrincipal = (StudyPrincipal) subject.getPrincipal();

        return 1 == studyPrincipal.getUserType();
    }
}
